import request from '@/request'
import type { TopicTypeData, CategoryTypeData } from '@/common/topic/topicType'
import type { TopicDetailType, Data } from '@/common/topic/topicDetailType'
import type { ApiResponse } from '@/common/requestType'

//获取指定分类下的话题列表api返回数据
export function getTopicList(
  category_id: number,
  page: number
): Promise<ApiResponse<TopicTypeData>> {
  return request({
    url: `/category/${category_id}/topic/${page}`,
    method: 'GET'
  })
}

//获取分类列表api返回数据
export function getCategoryList(
  type: string
): Promise<ApiResponse<CategoryTypeData[]>> {
  return request({
    url: `/category/${type}`,
    method: 'GET'
  })
}

//获取话题详情api返回数据
export function getTopicDetail(
  topic_id: number
): Promise<ApiResponse<TopicDetailType>> {
  return request({
    url: `/topic/${topic_id}`,
    method: 'GET'
  })
}

// 获取话题详情tabbar  Api返回数据
export function getTopicDetailTabbar(
  topic_id: number,
  page: number,
  tab: string
): Promise<ApiResponse<Data>> {
  return request({
    url: `/topic/${topic_id}/article/${page}?order=${tab}`,
    method: 'GET'
  })
}
